<template>
	<web-view v-if="url1" :src="url1"></web-view>
</template>

<script>
	const app = getApp();
	const network = require("@manager/network-manager.js");
	const dialog = require("@utils/dialog.js");
	const util = require("@utils/util.js");
	export default {
		data() {
			return {
				url1: null //要打开的外部链接
			}
		},
		onLoad: function(options) {
			//debugger
			this.url1 = options.url;
			//更新已读
			if (options.from == "message" || options.from == "notice") {
				this.update2Read(options.id, options.isType,options.from);
			}
		},
		methods: {
			update2Read: function(id,isType,from) {
				//debugger
				var that = this;
				//更新成已读
				var uri = app.globalData.config.interfaces.URL_SYS_SENDMSG_UPDATE_LEVCMSGUSERREADY;
				var params = {
					"id": id,
					"isType": isType
				};
				network.post(uri, params, 'json').then(res => {
					if (res.code == 200) {
						//debugger
						console.log("已读333", JSON.stringify(res));
						if(from=='message'){
							//回调上一个页面
							let pages = getCurrentPages();
							if(pages.length==3){
								let prePage = pages[pages.length - 2];
								let preprePage=pages[pages.length - 3]
								// #ifdef H5
								prePage.refresh(id);
								preprePage.refresh();
								// #endif
								// #ifdef APP-PLUS
								prePage.$vm.refresh(id);
								preprePage.$vm.refresh();
								// #endif
							}
						}else{
							let pages = getCurrentPages();
							let prePage = pages[pages.length - 2];
							// #ifdef H5
							prePage.refresh(id);
							// #endif
							// #ifdef APP-PLUS
							prePage.$vm.refresh(id);
							// #endif
						}
						util.syncBadge(getApp())
						
						// that.$util.prePage.refresh(id);
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}

				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
					console.error(res);
				});
			},

		}
	}
</script>

<style>

</style>
